﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InHD.model;
using InHD.commands;
using System.Windows.Input;

namespace InHD.viewmodels
{
    class AccReceivableListViewModel:WorkspaceViewModel
    {
        #region Value Property
        private List<Customer> _customerRowCollection;
        private int _customerRowIndex = -1;
        public string commandExcute = string.Empty;
        private Customer _customer;
        #endregion

        #region Constructor
        public AccReceivableListViewModel(List<Customer> listCustomer)
        {
            _customerRowCollection = listCustomer;
        }
        #endregion

        #region Presentation Property
        public List<Customer> CustomerRowCollection
        {
            get
            {
                return _customerRowCollection;
            }
            set
            {
                if (_customerRowCollection != value)
                {
                    _customerRowCollection = value;
                    OnPropertyChanged("CustomerRowCollection");
                }
            }
        }

        public int CustomerRowIndex
        {
            get
            {
                return this._customerRowIndex;
            }
            set
            {
                this._customerRowIndex = value;
                OnPropertyChanged("CustomerRowIndex");
            }
        }

        public Customer SelectedCustomer
        {
            get
            {
                return this._customer;
            }
            set
            {
                if (value != null)
                {
                    this._customer = value;
                }
            }
        }
        #endregion

        #region Command 
        private RelayCommand _viewTransactionListCommand;
        public ICommand ViewTransactionListCommand
        {
            get
            {
                if (_viewTransactionListCommand == null)
                {
                    _viewTransactionListCommand = new RelayCommand(
                        (param) => this.ViewTransactionList(), (param) => this.CanView);
                }
                return _viewTransactionListCommand;
            }
        }

        #endregion

        #region Command Method
        void ViewTransactionList()
        {
            commandExcute = "ViewTransactionList";
            OnRequestClose();
        }

        #endregion

        public bool CanView { get { return this.SelectedCustomer != null ? true : false; } }
    }
}
